/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.apiGenerator;

import com.inspur.edp.caf.generator.compileunit.CompileUnitGeneratorContext;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.overall.CefGeneratorContext;
import com.inspur.edp.lcm.metadata.api.service.GspProjectService;
import com.inspur.edp.lcm.metadata.api.service.MetadataService;
import io.iec.edp.caf.commons.utils.SpringBeanUtils;
import lombok.var;

public class CefApiGeneratorContext extends CompileUnitGeneratorContext {
  private CefGeneratorContext cefGenContext;

  public CefApiGeneratorContext(CefGeneratorContext cefGenContext) {
    super();
    this.cefGenContext = cefGenContext;
    privateEntityInterfaceTypes = new java.util.HashMap<String, MediateType>();
    privateEntityAllInterfaceTypes = new java.util.HashMap<String, MediateType>();
  }

  public CefGeneratorContext getCefGenContext() {
    return cefGenContext;
  }

  private java.util.HashMap<String, MediateType> privateEntityInterfaceTypes;

  public final java.util.HashMap<String, MediateType> getEntityInterfaceTypes() {
    return privateEntityInterfaceTypes;
  }

  private MediateType privateMgrInterfaceType;

  public final MediateType getMgrInterfaceType() {
    return privateMgrInterfaceType;
  }

  public final void setMgrInterfaceType(MediateType value) {
    privateMgrInterfaceType = value;
  }

  private java.util.HashMap<String, MediateType> privateEntityAllInterfaceTypes;

  public final java.util.HashMap<String, MediateType> getEntityAllInterfaceTypes() {
    return privateEntityAllInterfaceTypes;
  }

  private  MediateType rootEntityAllInterfaceType;
  public final  MediateType getRootEntityAllInterfaceType()
  {
    return rootEntityAllInterfaceType;
  }
  public  final  void setRootEntityAllInterfaceType(MediateType value)
  {
    rootEntityAllInterfaceType =value;
  }

  private MediateType privateMgrAllInterfaceType;

  public final MediateType getMgrAllInterfaceType() {
    return privateMgrAllInterfaceType;
  }

  public final void setMgrAllInterfaceType(MediateType value) {
    privateMgrAllInterfaceType = value;
  }

//  private MetadataProjectService projService;
  GspProjectService projService;
  /** 当前元数据工程SU */
  public String getProjectServiceUnit() {
    return cefGenContext.getMetadataJitContext().getGspProjectInfo().getServiceUnitCode();
  }

  /** 资源元数据ID */
  //
//  private MetadataService mdService;
  public final String getResourceMetadataId() {
//    MetadataService mdService = CefDesignTimeBeanUtil.getAppCtx().getBean(MetadataService.class);
    MetadataService mdService=SpringBeanUtils.getBean(MetadataService.class);
    var resourceMetaList=mdService.getResourceMetadata(cefGenContext.getMetadata().getHeader().getId(),cefGenContext.getMetadata().getRelativePath());
    var resourceMetaId=(resourceMetaList == null || resourceMetaList.size() == 0) ? "" : resourceMetaList.get(0).getId();
    return resourceMetaId;
  }

  private MediateType mgrInfoType;

  public final MediateType getMgrInfoType() {
    return mgrInfoType;
  }

  public final void setMgrInfoType(MediateType value) {
    mgrInfoType = value;
  }
}
